home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
32-bit_x86
/
Italiano
/
cpsimage.cab
/
data
/
pdf
/
ims2pdf.elf
< prev
Wrap
Text File
|
2009-03-16
|
2KB
|
70 lines
// The TimeCheck() function reports the time to this point in the execution
print "time to start interpreter = " + TimeCheck() + "secs";
// Load declarations and support procedures
#import "documentio.ucm";
#import "fiji2xip.ucm";
#import "fwx2xip.ucm";
#load "xipProcs/printLayer.proc";
#load "xipProcs/getOcrPage.proc";
#load "sys/stdlib.elf";
// Load image functions and methods
LoadClasses ( filename: "xeng" );
IMPORT STRING dir;
IMPORT STRING language = "English";
IMPORT INTEGER ocr = 1; // Default is on
STRING ocrformat = "XDOC";
STRING ocrxdoc, ocrxml;
FILE file = new (FILE, path:dir);
// Test for proper parameters
if ( !dir || !file.isDirectory() )
{ print "Usage: \"xipe ims2pdf.elf -im dir:s language:s ocr:i 0|1\" " +
"\n\twhere dir is a directory with images to be packaged"; end; }
LIST filelist = file.list ();
STRING outpdf = dir.name() + ".pdf";
// Make a DOCUMENTWRITER
print "creating PDF writer";
DOCUMENTWRITER docwrite = CreateDocumentWriter (filename:outpdf);
// Read and segment image
XIPIMAGE ims, thumb, ocrimg;
INTEGER i;
for (i=0; filelist[i]; i++) {
ims = ReadIMS (filename: dir + "/" + filelist[i]);
// Add thumbnail to segmented image
if (ims.getMember (member: "layerType") == XIP_Binary)
ims.addLayer(image:ims.unCompress().invert().thumbnail( size: (150,150)),
ltype: XIP_Thumbnail);
else
ims.addLayer(image:ims.unCompress().thumbnail( size: (150,150)),
ltype: XIP_Thumbnail);
if (ocr) {
print "OCR " + file + "...";
ocrimg = getOcrPage (input: ims);
ocrxdoc = ocrimg.fwxOCR (texttype: ocrformat, language: language);
XIPIMAGE ocrxip = XDOCtoXIPXML(xdoc: ocrxdoc);
ocrxip.setMember(num:0, member:"visibility", value: FALSE);
ims.addLayer(image:ocrxip, ltype: XIP_Text);
}
// Add page to the DOCUMENT
docwrite.appendPage (pgImg: ims);
}
docwrite.release();
// How long has this taken
print TimeCheck();
print "output pdf file = " + outpdf;